package com.rainbow.commons.mybatis;

import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
import com.baomidou.mybatisplus.toolkit.IdWorker;
import org.apache.ibatis.reflection.MetaObject;

import java.util.Date;

/**
 * @author Rainbow on 2018/6/27
 */
public class SuperMetaObjectHandler extends MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("id", String.valueOf(IdWorker.getId()), metaObject);
        setFieldValByName("createTime", new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {

        setFieldValByName("updateTime", new Date(), metaObject);

    }
}
